<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>考试第九题</title>
</head>

<body>

</body>
<script>
    /* 去除数组1[1,2,3,4,5]与数组2[1,3,5,7,9]中共同的元素 */
    let arr1 = [1, 2, 3, 4, 5];
    let arr2 = [1, 3, 5, 7, 9];
    for (let i = 0; i < arr1.length; i++) {
        if (arr2.indexOf(arr1[i]) != -1) {
            let index = arr2.indexOf(arr1[i]);
            arr1.splice(i, 1);
            arr2.splice(index, 1);
            i--;
        }
    }
    document.write('数组1去重后：' + arr1 + '<br/>');
    document.write('数组2去重后：' + arr2);
</script>

</html>